<%@page import="org.blackjuly.sign.data.SystemDataSource"%>
<%@page import="org.blackjuly.sign.util.JdbcUtil"%>
<%@page import="java.sql.Connection"%>
<%@page import="org.blackjuly.sign.service.UserService"%>
<%@page import="org.blackjuly.sign.entity.User"%>
<%@page import="org.blackjuly.sign.web.RequestManager"%>
<%@page language="java" pageEncoding="utf-8" contentType="text/html; charset=utf-8"%>

<%
RequestManager rm = new RequestManager(request);
User user = rm.getModel(User.class);
UserService userService = new UserService();
Connection conn = SystemDataSource.getInstance().getConnection();
userService.setConnection(conn);
String msg = "";
String url = "index.jsp";
if(!userService.checkHas(user)){//判断是否有该学生
	msg = "没有这个学生，三秒后跳转签到页面";
}else if(!userService.checkRegiste(user)) {//判断是否签到过
	userService.sign(user);
	SystemDataSource.commit(conn);
	session.setAttribute("user", user);
	msg = "签到成功，三秒后自动登录";
	url = "home.jsp";
}else{
	msg = "已经签到过了，请直接登录，三秒后跳转";
}
SystemDataSource.close(conn);
out.print(msg);
response.setHeader("refresh", "3;URL=" + url);
%>